// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import App from './App';
import router from './router';
import Mint from 'mint-ui';
import Vant from 'vant';
import 'vant/lib/index.css';
import 'mint-ui/lib/style.css';
import loading from '@/components/common/load';
import popup from '@/components/common/popup';
import qcell from '@/components/common/qcell';
import listload from '@/components/common/listload';
import Spread from '@/components/common/data/method/spread.js';
import Cart from '@/components/common/data/method/cart.js';
import sale from '@/components/common/data/method/sale.js';
import Index from '@/components/common/data/method/index.js';
import UserReq from './components/common/data/method/UserReq';
import LoginReq from './components/common/data/method/LoginReq';
import Public from '@/assets/js/public.js';
import store from '@/store';
import fundebug from 'fundebug-javascript';

Vue.prototype.$Spread = Spread;
Vue.prototype.$Cart = Cart;
Vue.prototype.$Sale = sale;
Vue.prototype.$Index = Index;
Vue.prototype.$UserReq = UserReq;
Vue.prototype.$Public = Public;
Vue.prototype.$LoginReq = LoginReq;
Vue.use(Mint);
Vue.use(Vant);
Vue.use(loading);
Vue.use(popup);
Vue.use(qcell);
Vue.use(listload);
Vue.config.productionTip = false;

fundebug.apikey = '4fea4811ba871e123b601ea48eb37859ee5f24936c43bdef758dd75cbf1538e2';

function formatComponentName(vm) {
  if (vm.$root === vm) return 'root';
  let name = vm._isVue ? (vm.$options && vm.$options.name) || (vm.$options && vm.$options._componentTag) : vm.name;
  return (name ? 'component <' + name + '>' : 'anonymous component') + (vm._isVue && vm.$options && vm.$options.__file ? ' at ' + (vm.$options && vm.$options.__file) : '');
}

Vue.config.errorHandler = function (err, vm, info) {
  let componentName = formatComponentName(vm);
  let propsData = vm.$options && vm.$options.propsData;

  fundebug.notifyError(err,
    {
      metaData:
        {
          componentName: componentName,
          propsData: propsData,
          info: info
        }
    });
};
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>'
});
